<!--进厂业务模块-->
<template>
  <div  style="position: relative;">
    <mmTable ref="mmTable" :mmColumns="columns" :getUrl="url" :updateUrl="updateUrl" :delUrl="delUrl"
             :form="form" :formData="formData" v-on:formDataChange="formDataChange"
             :searchFormData="searchFormData" :searchForm="searchForm"
             :modalWidth="1000">
      <Form slot="searchForm" ref="searchForm" :model="searchFormData" inline :label-width="70"  style="float: left">
        <FormItem label="用户名" prop="">
          <Input v-model="searchFormData.name" type="text" placeholder="" />
        </FormItem>
      </Form>
      <!--编辑添加模态框-->
      <Form  slot="editForm" :label-width="100" :model="formData" inline ref="editForm" :rules="formValidate">

        <Row>
          <Col :span="8">
          <FormItem label="车牌" prop="car" style="width:300px">
            <Input v-model="formData.car" @on-enter="keydown"/>
          </FormItem>
          </Col>
          <Col :span="8">
          <FormItem label="计划日期" prop="plantime" style="width:300px">
            <Input v-model="formData.plantime" readonly/>
          </FormItem>
          </Col>
          <Col :span="8">
          <FormItem label="计划人" prop="plancreatorname" style="width:300px">
            <Input v-model="formData.plancreatorname" readonly/>
          </FormItem>
          </Col>
        </Row>
        <Row>
          <Col :span="8">
          <FormItem label="供货商" prop="companyname" style="width:300px">
            <Input v-model="formData.companyname" readonly/>
          </FormItem>
          </Col>
          <Col :span="8">
          <FormItem label="货物" prop="materialname" style="width:300px">
            <Input v-model="formData.materialname" readonly/>
          </FormItem>
          </Col>
          <Col :span="8">
          <FormItem label="批次号" prop="planbillcode" style="width:300px">
            <Input v-model="formData.planbillcode" readonly/>
          </FormItem>
          </Col>
        </Row>
        <Row>
          <Col :span="8">
          <FormItem label="计划毛重" prop="plangross" style="width:300px">
            <Input v-model="formData.plangross" readonly/>
          </FormItem>
          </Col>
          <Col :span="8">
          <FormItem label="计划皮重" prop="plantare" style="width:300px">
            <Input v-model="formData.plantare" readonly/>
          </FormItem>
          </Col>
          <Col :span="8">
          <FormItem label="计划实重" prop="planreal" style="width:300px">
            <Input v-model="formData.planreal" readonly/>
          </FormItem>
          </Col>
        </Row>
        <Row>
        <Col :span="24">
        <FormItem label="备注" prop="memo" style="width:900px">
          <Input v-model="formData.memo" type="textarea" height="300"/>
        </FormItem>
        </Col>
        </Row>
      </Form>
    </mmTable>
  </div>
</template>


<script>
  import mmTable from '../components/mmtable/mmtable.vue';
  import {getInPlanByCar} from '@/api/busi'
  export default {
    components: {
      mmTable
    },
    data () {
      /*显示列表*/
      return {
        columns:[
          {title: "编号",key: "billcode",width:200,align:'center'},
          {title: "车牌",key: "car",width:200,align:'center'},
          {title: "计划日期",key: "plantime",width:200,align:'center'},
          {title: "创建时间",key: "createtime",width:200,align:'center'},
          {title: "计划人",key: "plancreatorname",width:200,align:'center'},
          {title: "创建人",key: "creatorname",width:200,align:'center'},
          {title: "供货商",key: "companyname",width:200,align:'center'},
          {title: "货物",key: "materialname",width:200,align:'center'},
          {title: "计划毛重",key: "plangross",width:200,align:'center'},
          {title: "计划皮重",key: "plantare",width:200,align:'center'},
          {title: "计划实重",key: "planreal",width:200,align:'center'},
          {title: "金额",key: "money",width:200,align:'center'},
          {title: "备注",key: "memo",align:'left',width:200}
        ],
        /*链接后台*/
        url:'/instation/getList',
        updateUrl:'/instation/Save',
        delUrl:'/instation/Delete',
        form:{},
        formValidate:{
        },
        searchForm:{},
        searchFormData:{
          code:'',
          name:''
        },
        /*后台传的数据*/
        formData:{
          car:'',
          plantime:'',
          plancreatorname:'',
          companyname:'',
          materialname:'',
          planbillcode:'',
          plangross:'',
          plantare:'',
          planreal:'',
          memo:''
        },
        searchFormData:{
          name:""
        },
        searchForm:{}
      }
    },
    mounted () {
      this.form = this.$refs.editForm;
      this.searchForm = this.$refs.searchForm;
    },

    /*方法*/
    methods: {
      formDataChange(data){
        this.formData = data;
      },
      keydown(){
          let that =this;
        if(this.formData.car){
          getInPlanByCar({ car: this.formData.car }).then(res => {
            if(res.data.code ==200){
                if(res.data.data){
                    let id ='';
                  if(that.formData.id){
                    id=that.formData.id;
                  }
                  that.formData=res.data.data;
                  that.formData.id =id;
                }else{
                  that.$Message.error("未找到对应批次")
                }
            }else {
              that.$Message.error(res.data.msg)
            }
          });
        }
      }
    }
  }
</script>

<style>

</style>
